﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
using System.Drawing.Imaging;
using Maticsoft.Common;



namespace WEB
{
    public partial class checkImage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ///使用 getchecknum() 函数生成验证码

                getchecknum rangString = new getchecknum();
                string checknum = rangString.getnum(6);

                ///将验证码存入Session 中，等待跨页面调用

                Session["checknum"] = checknum;

                ///使用 RandImage() 函数，将生成的验证码转换为图片

                RandImage randImage = new RandImage(90, 28, 6, checknum);
                System.Drawing.Image image = randImage.GetImage();
                System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
                image.Save(memoryStream, ImageFormat.Jpeg);
                Response.ClearContent();
                Response.ContentType = "image/gif";
                Response.BinaryWrite(memoryStream.ToArray());
                image.Dispose();
                Response.End();
            }


        }
    }
}
